package fr.afcepf.atod.gestionVP.data;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="employe")
@DiscriminatorColumn(name="typeEmploye",
		    discriminatorType=DiscriminatorType.STRING,length=12)
@DiscriminatorValue(value="EMPLOYE")
public class Employe {
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	private String nom;
	private String adresse;
	private String prenom;
	private Double salaireFixeHoraire;
	
	@ManyToOne
	private Pole pole;
	
	public Integer getId() {
		return id;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getNom() {
		return nom;
	}
	
	public void setNom(String nom) {
		this.nom = nom;
	}
	
	public String getAdresse() {
		return adresse;
	}
	
	public void setAdresse(String adresse) {
		this.adresse = adresse;
	}
	
	public String getPrenom() {
		return prenom;
	}
	
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}
	
	public Double getSalaireFixeHoraire() {
		return salaireFixeHoraire;
	}
	
	public void setSalaireFixeHoraire(Double salaireFixeHoraire) {
		this.salaireFixeHoraire = salaireFixeHoraire;
	}
	
	public Pole getPole() {
		return pole;
	}

	public void setPole(Pole pole) {
		this.pole = pole;
	}

	public Employe() {
		
	}
	
	public Employe(String nom, String adresse, String prenom, Double salaireFixeHoraire) {
		this.nom = nom;
		this.adresse = adresse;
		this.prenom = prenom;
		this.salaireFixeHoraire = salaireFixeHoraire;
	}

	@Override
	public String toString() {
		return "Employe [adresse=" + adresse + ", id=" + id + ", nom=" + nom
				+ ", prenom=" + prenom + ", salaireFixeHoraire="
				+ salaireFixeHoraire + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((adresse == null) ? 0 : adresse.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((nom == null) ? 0 : nom.hashCode());
		result = prime * result + ((prenom == null) ? 0 : prenom.hashCode());
		result = prime
				* result
				+ ((salaireFixeHoraire == null) ? 0 : salaireFixeHoraire
						.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Employe other = (Employe) obj;
		if (adresse == null) {
			if (other.adresse != null)
				return false;
		} else if (!adresse.equals(other.adresse))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (nom == null) {
			if (other.nom != null)
				return false;
		} else if (!nom.equals(other.nom))
			return false;
		if (prenom == null) {
			if (other.prenom != null)
				return false;
		} else if (!prenom.equals(other.prenom))
			return false;
		if (salaireFixeHoraire == null) {
			if (other.salaireFixeHoraire != null)
				return false;
		} else if (!salaireFixeHoraire.equals(other.salaireFixeHoraire))
			return false;
		return true;
	}
	
	
}
